#include "Entity.h"

#include <SDL_mixer.h>

#include <graphic/AnimatedDrawable.h>
#include <graphic/Drawable.h>
#include <utils/ResourceManager.h>

void Entity::collide(Entity* other) {

    if ((type == PLAYER && other->type == ENEMY) ||
        (type == ENEMY && other->type == PLAYER) ||
        (type == PLAYER && other->type == MINES) ||
        (type == MINES && other->type == PLAYER)) {            
            if (Globals::gCharacterManager->removeChild()) {
                Mix_PlayChannel(-1, Globals::gResourceManager->getSound("removeChild"), 0);
            }       
    }   

    if ((type == PLAYER && other->type == CHILD)) {
		other->type = NONE;
        Mix_PlayChannel(-1, Globals::gResourceManager->getSound("addChild"), 0);
        Globals::gCharacterManager->addChild(static_cast<AnimatedDrawable*> (other->mDrawable));
    } else if ((type == CHILD && other->type == PLAYER)) {
		type = NONE;
        Mix_PlayChannel(-1, Globals::gResourceManager->getSound("addChild"), 0);
        Globals::gCharacterManager->addChild(static_cast<AnimatedDrawable*> (mDrawable));
    } 
}

Entity::Entity() 
    : type(NONE)
    , id(0)
    , staticObject(false)
    , pisycs(false)
    , mDrawable(nullptr)
{

}